package game.model.compare;

import common.model.compare.BaseCompare;
import common.model.enums.ClassificationTypeEnum;
import lombok.Data;

import java.util.Objects;

/**
 * @author 米泽鹏
 * @since 2022-3-8 下午 9:05
 */
@Data
public class GClassificationCompare extends BaseCompare {

	/**
	 * 父级类别id，0表示顶级类别
	 */
	private Long parentId;

	/**
	 * 类型
	 */
	private ClassificationTypeEnum type;

	/**
	 * 同级类别中的排序
	 */
	private Integer sort;

	/**
	 * 类别名称
	 */
	private String name;

	/**
	 * treeNodeId
	 * el-tree组件每个节点的id，在一棵树中必然存在且是唯一的
	 */
	private Long treeNodeId;

	/**
	 * 父级节点的treeNodeId
	 */
	private Long parentTreeNodeId;

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (!(o instanceof GClassificationCompare)) {
			return false;
		}
		if (!super.equals(o)) {
			return false;
		}
		GClassificationCompare compare = (GClassificationCompare) o;
		return Objects.equals(getParentId(), compare.getParentId()) && Objects.equals(getSort(), compare.getSort()) && Objects.equals(getName(), compare.getName());
	}

	@Override
	public int hashCode() {
		return Objects.hash(super.hashCode(), getParentId(), getSort(), getName());
	}

}
